//-----------------------------------------------------------------------------
// Name: Bridge.cpp
// Auth: Carlos Betancourt
// Desc: Moves a Jet around in 2D
//-----------------------------------------------------------------------------

#include "Bridge.h"

#include "SharedConstants.h"

#include "corona/corona.h"

#include <GL/glut.h>//<GL/glut.h>
#include <math.h>

//-----------------------------------------------------------------------------
// Globals:
//-----------------------------------------------------------------------------
cBridge gBridge;


//-----------------------------------------------------------------------------
// Functions:
//-----------------------------------------------------------------------------
cBridge* GetBridge()
{
	return &gBridge;
}

//-----------------------------------------------------------------------------
// class cBridge:
//-----------------------------------------------------------------------------
cBridge::cBridge():cDrawable( 8.0f )
{

}

cBridge::~cBridge()
{
}



void cBridge::Draw()
{
  glPushMatrix();

  glTranslatef( 0.0f, 5.5f, 0.0f );
  glRotatef( -90.0f, 0.0f, 1.0f, 0.0f );

	//Top of ROAD --Looking From Bellow
	glBegin(GL_QUADS);
	 glColor3f(0.2f, 0.2f, 0.2f);
	 glVertex3f(-4.0f, 0.5f, -8.0f); //vertex2 --original
	 glVertex3f(4.0f, 0.5f, -8.0f); //vertex3--original
	 glVertex3f(4.0f, 0.5f, 8.0f); //vertex4 --origial
	 glVertex3f(-4.0f, 0.5f, 8.0f); //vertex1 --original

	//Top of ROAD-- Looking from Above
	 glVertex3f(-4.0f, 0.5f, 8.0f); //vertex1(mirror)
	 glVertex3f(4.0f, 0.5f, 8.0f); //vertex4(mirror)
	 glVertex3f(4.0f, 0.5f, -8.0f); //vertex3(mirror)
	 glVertex3f(-4.0f, 0.5f, -8.0f); //vertex2(mirror)

	 //DiagonalRectangle(CloserFace)--Looking from Bellow
	 glColor3f(0.5f, 0.5f, 0.5f);
	 glVertex3f(-4.0f, 0.5f, 0.0f);
	 glVertex3f(4.0f, 0.5f, 0.0f);
	 glVertex3f(4.0f, -2.5f, 5.0f);
	 glVertex3f(-4.0f, -2.5f, 5.0f);

	 //DiagonalRactangle(FurtherFace)--Looking from Bellow
	 glVertex3f(4.0f, 0.5f, 0.0f);
	 glVertex3f(-4.0f, 0.5f, 0.0f);
	 glVertex3f(-4.0f, -2.5f, -5.0f);
	 glVertex3f(4.0f, -2.5f, -5.0f);

	 //CloserFace--RightFace
	 glColor3f(0.5f, 0.5f, 0.5f);
	 glVertex3f(-4.0f, 0.5f, 5.0f);//
	 glVertex3f(4.0f, 0.5f, 5.0f); 
	 glVertex3f(4.0f, -5.5f, 5.0f); 
	 glVertex3f(-4.0f, -5.5f, 5.0f); 

	 //CloserFace--RightFace(mirror)
	 glVertex3f(-4.0f, -5.5f, 8.0f);//V6
	 glVertex3f(4.0f, -5.5f, 8.0f);//V5
	 glVertex3f(4.0f, 0.5f, 8.0f);//V4
	 glVertex3f(-4.0f, 0.5f, 8.0f);//V1

	 //FurhterFace--LeftFace
	 glVertex3f(-4.0f, 0.5f, -8.0f);//
	 glVertex3f(4.0f, 0.5f, -8.0f);//
	 glVertex3f(4.0f, -5.5f, -8.0f);//
	 glVertex3f(-4.0f, -5.5f, -8.0f);//

	 //FurtherFace--LeftFace(mirror)
	 glVertex3f(-4.0f, -5.5f, -5.0f);
	 glVertex3f(4.0f, -5.5f, -5.0f);
	 glVertex3f(4.0f, 0.5f, -5.0f);
	 glVertex3f(-4.0f, 0.5f, -5.0f);

	 //SideWall_1(backright)
	 glColor3f(0.8f, 0.8f, 0.8f);
	 glVertex3f(4.0f, -5.5f, 5.0f); //V7
	 glVertex3f(4.0f, 0.5f, 5.0f);//V14
	 glVertex3f(4.0f, 0.5f, 8.0f);
	 glVertex3f(4.0f, -5.5f, 8.0f);
	
	 //SideWall_1(frontright)
	 glVertex3f(-4.0f, -5.5f, 8.0f);
	 glVertex3f(-4.0f, 0.5f, 8.0f);
	 glVertex3f(-4.0f, 0.5f, 5.0f);//V14
	 glVertex3f(-4.0f, -5.5f, 5.0f); //V7

	 //SideWall_(frontLeft)
	 glVertex3f(-4.0f, -5.5f, -5.0f); //V7
	 glVertex3f(-4.0f, 0.5f, -5.0f); //V7
	 glVertex3f(-4.0f, 0.5f, -8.0f); //V7
	 glVertex3f(-4.0f, -5.5f, -8.0f); //V7

	//SideWall(BackLeft)
	 glVertex3f(4.0f, -5.5f, -8.0f);
	 glVertex3f(4.0f, 0.5f, -8.0f); //V7
	 glVertex3f(4.0f, 0.5f, -5.0f);
	 glVertex3f(4.0f, -5.5f, -5.0f);

	 //SideWall(Bottom_Closer)
	 glVertex3f(-4.0f, -5.5f, 8.0f);
	 glVertex3f(-4.0f, -5.5f, 5.0f);
	 glVertex3f(4.0f, -5.5f, 5.0f);
	 glVertex3f(4.0f, -5.5f, 8.0f);

	 //SideWall(Bottom_Further)
	 glVertex3f(-4.0f, -5.5f, -5.0f);
	 glVertex3f(-4.0f, -5.5f, -8.0f);
	 glVertex3f(4.0f, -5.5f, -8.0f);
	 glVertex3f(4.0f, -5.5f, -5.0f);

	 //Drawing the left line
	 glColor3f(1.0f, 1.0f, 1.0f); //color = White
	 glVertex3f(-0.5f, 0.5f, 8.0f); //vertex1(mirror)
	 glVertex3f(-0.3f, 0.5f, 8.0f); //vertex4(mirror)
	 glVertex3f(-0.3f, 0.5f, -8.0f); //vertex3(mirror)
	 glVertex3f(-0.5f, 0.5f, -8.0f); //vertex2(mirror)

	 //Drawing the right line
	 glVertex3f(0.3f, 0.5f, 8.0f); //vertex1(mirror)
	 glVertex3f(0.5f, 0.5f, 8.0f); //vertex4(mirror)
	 glVertex3f(0.5f, 0.5f, -8.0f); //vertex3(mirror)
	 glVertex3f(0.3f, 0.5f, -8.0f); //vertex2(mirror)
	
	glEnd();

	glBegin(GL_TRIANGLES);
	 glColor3f(0.8f, 0.8f, 0.8f);

	 //Triangle_BackSide_CloserFace
	 glVertex3f(-4.0f, 0.5f, 5.0f);
	 glVertex3f(-4.0f, 0.5f, 0.0f);
	 glVertex3f(-4.0f, -2.5f, 5.0f);

	 //Triangle_BackSide_CloserFace(mirror)
	 glVertex3f(-4.0f, -2.5f, 5.0f);
	 glVertex3f(-4.0f, 0.5f, 0.0f);
	 glVertex3f(-4.0f, 0.5f, 5.0f);

	 //Triangle_BackSide_FurhterFace
	 glVertex3f(-4.0f, -2.5f, -5.0f);
	 glVertex3f(-4.0f, 0.5f, 0.0f);
	 glVertex3f(-4.0f, 0.5f, -5.0f);

	 //Tirangle_BackSide_FurtherFace(mirror)
	 glVertex3f(-4.0f, 0.5f, -5.0f);
	 glVertex3f(-4.0f, 0.5f, 0.0f);
	 glVertex3f(-4.0f, -2.5f, -5.0f);

	 //Triangle_FrontSide_CloserFace
	 glVertex3f(4.0f, 0.5f, 5.0f);
	 glVertex3f(4.0f, 0.5f, 0.0f);
	 glVertex3f(4.0f, -2.5f, 5.0f);

	 //Triangle_FrontSide_CloserFace(mirror)
	 glVertex3f(4.0f, -2.5f, 5.0f);
	 glVertex3f(4.0f, 0.5f, 0.0f);
	 glVertex3f(4.0f, 0.5f, 5.0f);

	 //Triangle_FrontSide_FurhterFace
	 glVertex3f(4.0f, -2.5f, -5.0f);
	 glVertex3f(4.0f, 0.5f, 0.0f);
	 glVertex3f(4.0f, 0.5f, -5.0f);

	 //Tirangle_FrontSide_FurtherFace(mirror)
	 glVertex3f(4.0f, 0.5f, -5.0f);
	 glVertex3f(4.0f, 0.5f, 0.0f);
	 glVertex3f(4.0f, -2.5f, -5.0f);

	glEnd();

  glPopMatrix();
}